import BaseView from "../baseView.js";

export default class adminsdetail extends BaseView {
    //修改构造函数
    constructor(id, studentId) {
        super(id);
        //获得传过来的参数的值 并赋值给详情页面的属性this.studentId赋值
        this.studentId = studentId;
        //console.log("详细信息页面：studentId==>>"+studentId);
        //挂载数据
        this.mouted()
    }
    //挂载数据
    mouted() {
        //console.log("详细页面需要查询：="+this.studentId)
        //发送ajax
        $.ajax({
            type: "get",
            url: "/admins/xiangqing/" + this.studentId,
            DataType: "json",
            success: (data) => {
                console.log(data);
                if (data.code == 1) {
                    let res = data.msg;
                    $("#movieId").val(res.adminName);
                    $("#cinemasId").val(res.adminPassword);
                    //渲染页面
                    // myform.render();

                    // 获取照片的路径
                    $('#imgages').attr('src', `../../images/${res.photo}`);
                } else {
                    alert(data.msg)
                }
            }
        })
    }

    render() {
        $("#Content").html(`
             <div>
             <div style="margin: 30px 10px 0 20px ">
             <span class="layui-breadcrumb" style="visibility: visible;">
                 <a>学生管理系统/</a>/
                 <a>学生资料管理/</a>/
                 <a>详细信息</a>
              </span>
              <hr/>
             </div>
             <div>
             <form class="layui-form" id = "addGoodsForm">

             <div class="layui-form-item">
            <label class="layui-form-label">头像:</label>
             <img  id= "imgages" alt="他怎么不见了呀"; style="width: 50px;height: 50px;border-radius: 50px; margin-left:0px">
            </div>

         <div class="layui-form-item">
         <label class="layui-form-label">管理员账号:</label>
           <div class="layui-input-block">
             <input type="text" id="movieId" required   placeholder="请输入注册账号"  class="layui-input">
           </div>
         </div>
         <div class="layui-form-item">
         <label class="layui-form-label">管理员密码:</label>
           <div class="layui-input-block">
             <input type="text" id="cinemasId" required   placeholder="请输入管理员"  class="layui-input">
           </div>
         </div>

         
         

         </div>
         </div>
         <div class="layui-form-item">
           <div class="layui-input-block">
             <button type="reset" class="layui-btn layui-btn-primary" id="back">返回</button>
           </div>
         </div>
       </form>
             </div>
             
             </div>
            `)
    }
    handle() {
        $("#addLayuijs").html(`
       <script>
        layui.use('form', function(){
        var form = layui.form;
         //重新渲染表单
         form.render();
        });
        </script>
         `)

        $("#back").click(() => {
            window.location.hash = "#/main/adminsList";
        })
    }
}